package com.zhumo.sz.controller;

import com.zhumo.sz.common.CommonInsert;
import com.zhumo.sz.common.Result;
import com.zhumo.sz.entity.bus.*;
import com.zhumo.sz.service.TransitService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Select;
import org.apache.kafka.common.protocol.types.Field;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jiaqi.zhu
 * @time  2024-03-18
 * @comment 公交车与客运控制层
 */

@Slf4j
@RestController
@RequestMapping("/sz/service/transit")
public class TransitController {

    @Autowired
    private TransitService transitService;



    /**
     * 增加长途客运车
     *
     * @param num
     * @return
     */

    @RequestMapping("/addBus")
    public Result<String> addLengthBusses(@RequestParam int num) {
        CommonInsert<LengthBus> lengthBusCommonInsert = transitService.addLengthBus(100);
        String message = "插入" + lengthBusCommonInsert.getResult() + "条长途客运车信息";
        log.info(message);
        return Result.ok();
    }

    /**
     * 插入调度信息
     * @param stations
     * @param depNum
     * @return
     */
    @RequestMapping("addSch")
    public Result<String> addLengthBusSchedule(@RequestParam String stations,@RequestParam int depNum){
        CommonInsert<LengthBusDepartureScheduleInfo> scheduleInfoCommonInsert = transitService.addLengthBusSchedule(stations,depNum);
        String mesaage = "插入" + scheduleInfoCommonInsert.getResult() +"客运站调度信息";
        log.info(mesaage);
        return Result.ok();
    }

    /**
     * 删除市内公交车信息
     *
     * @param busId
     * @return
     */
    public Result<String> deletedBuses(@RequestParam int busId, @RequestParam boolean physical) {
        return Result.ok();
    }


    /**
     * 插入公交线路
     * @return
     */
    @RequestMapping("/addBusLine")
    public Result<String> addBusLine(@RequestParam String version){
        CommonInsert<BusLineInfo> busLineInfoCommonInsert = transitService.addBusLine(version);
        String message = "增加" + busLineInfoCommonInsert.getResult() + "条市内公交线路信息";
        log.info(message);
        return Result.ok(message);
    }

    /**
     * 插入公交车线路信息
     * @param version
     * @return
     */
    @RequestMapping("/addBusSite")
    public Result<String> addLengthBusStation(@RequestParam String version){
        CommonInsert<BusSiteInfo> busSiteInfoCommonInsert = transitService.addBusStation(version);
        String message = "增加" + busSiteInfoCommonInsert.getResult() + "条市内公交站点信息";
        log.info(message);
        return Result.ok(message);
    }

    /**
     * 公交车订单
     * @return
     */
    @RequestMapping("/addBusOrder")
    public Result<String> addLengthBusStation(@RequestParam int num,@RequestParam String date,@RequestParam String type){
        CommonInsert<BusOrderDetail> busOrderDetailCommonInsert = transitService.addBusOrder(num,date,type);
        String message = "增加" + busOrderDetailCommonInsert.getResult() + "公交车市内订单";
        log.info(message);
        return Result.ok(message);
    }


    /**
     * 插入长途站点信息
     * @param version
     * @return
     */
    @RequestMapping("/addLengthBusSt")
    public Result<String> addBusStation(@RequestParam String version){
        CommonInsert<LengthBusStationInfo> busSiteInfoCommonInsert = transitService.addLengthBusStation(version);
        String message = "增加" + busSiteInfoCommonInsert.getResult() + "条市长途客运站信息";
        log.info(message);
        return Result.ok(message);
    }


    /**
     * 生成公交车乘坐订单
     * @param date
     * @param num
     * @return
     */
    public Result<String> addBusOrder(@RequestParam String date,@RequestParam int num){
        return Result.ok();
    }
}